//617. 合并二叉树

#include <stdlib.h>
 struct TreeNode {
    int val;
    struct TreeNode *left;
    struct TreeNode *right;
};
struct TreeNode* mergeTrees(struct TreeNode* root1, struct TreeNode* root2){
    if(root1) return root2;
    if(root2) return root1;

    struct TreeNode* root = (struct TreeNode*)malloc(sizeof(struct TreeNode));
    root->val = root1->val + root2->val;

    root->left = mergeTrees(root1->left, root2->left);
    root->right = mergeTrees(root1->right, root2->right);
    return root;
}